package com.alavente.forms;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class LoginForm extends ActionForm {
	
	private int numUser;
	private String login;
	private String mdp;
	
	@Override
	public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
		
		ActionErrors errors = new ActionErrors();
		
		if (getLogin().isEmpty()) {
			errors.add("titre", new ActionMessage("error.login.required"));
		}
		
		if (getMdp().isEmpty()) {
			errors.add("password", new ActionMessage("error.mdp.required"));
		}
		
		return errors;
	}
	
	public int getNumUser() {
		return numUser;
	}
	public void setNumUser(int numUser) {
		this.numUser = numUser;
	}
	public String getLogin() {
		return login;
	}
	public void setLogin(String login) {
		this.login = login;
	}
	public String getMdp() {
		return mdp;
	}
	public void setMdp(String mdp) {
		this.mdp = mdp;
	}
	
	private static final long serialVersionUID = 1L;
}
